<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function maxTwo(list) {
            let max = -Infinity,
                secondMax = -Infinity;
            for (const x of list) {
                if (x > max) {
                    secondMax = max;
                    max = x;
                } else if (x > secondMax) {
                    secondMax = x;
                }
            }
            return [max, secondMax];
        }

        const maxTwo = (arr) => {
            const max = Math.max(...arr);
            const secondMax = Math.max(...arr.filter((a) => a !== max));
            return [max, secondMax];
        }; l
    </script>
</body>

</html>